<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="exporter-version" content="Evernote Mac 9.4.6 (461470)"/><meta name="author" content="704206198@qq.com"/><meta name="created" content="2017-10-17 03:36:44 +0000"/><meta name="source" content="desktop.mac"/><meta name="updated" content="2021-06-24 07:44:09 +0000"/><title>DAY08：Math和Date</title></head><body><div><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">1.什么是对象</span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    对象的类型是Object。</span></span></span></div><div><br/></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    JS中所有的事物都是对象：字符串，数值，数组，函数</span></span><span style="caret-color: rgb(51, 51, 51); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">……</span></font></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    JS中的万物皆对象。</span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    官方的解释：</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    什么是对象，其实就是一种类型，即引用类型，而对象的值就是引用类型的实例，在ECMAScript中引用类型是一种数据结构，用于将数据和功能组织在一起。它也常常被称为类，但ECMAScript中却没有类，虽然ECMAScript是一门面向对象的语言，却不具备传统面相对象语言所支持的类等基本结构</span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    想要对象怎么办？创建一个呗</span></span></span></div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">2.创建对象</span></span></span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    var obj = {}                //字面量</span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    var obj2 = new Object()     //构造函数</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    console.log( obj == obj2 )  //false</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">所有对象都不相等</span></div><div><br/></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    var obj = { a:10 </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">}</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    var obj2 = { b:10 }</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    console.log( obj.a == obj2.b )    //true</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;"> 对象</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">身上的属性，相当于一个变量，当值一样的时候，属性相等</span></font></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    存储数据的载体称为变量，在对象中称为</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">属性</span></font></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    功能实现的载体称为函数，在对象中称为</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">方法</span></font></span></span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    面向对象，就是只对 对象进行编程</span></span></span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">this，指针，是函数中的关键字。它的指向规则是当前方法执行的对象</span></div><div><span style="font-size: 14px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(229, 229, 229); color: rgb(51, 51, 51); font-family: 微软雅黑; font-variant-caps: normal; font-variant-ligatures: normal;">    this所在函数没有明确的隶属对象，this指向window</span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    var obj = {</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        name:"admin",</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        show:function(){</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            console.log(obj.name);</span></span></span></span></span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    console.log(this.name);</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        }</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    };</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    obj.show()        //admin        //admin</span></span></span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    函数中指向window的this，同理</span></span></span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    如何删除对象中的属性？</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    var obj = {</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        name:"admin",</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        age:23,</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">  </span> <span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">     like:"篮球"</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    }</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span> <span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">delete obj.name;</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><font face="Courier New" style="font-size: 10pt;"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51); font-weight: bold;">    delete obj.age;</span></font></span></span></span></span></div><div><font face="Courier New" style="font-size: 10pt;"><br/></font></div><div><font face="Courier New" style="font-size: 10pt;"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    小练习，创建一个属于自己的对象，并在对象中定一个方法，让该方法</span></span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">用字符串拼接的方式</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">输出</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><font face="Courier New" style="font-size: 10pt;"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    1.自己</span><span style="background-color: rgb(251, 250, 248); font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">的姓名</span></font></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    2.自己的年龄</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    3.自己的爱好</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 10pt; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    4.一个小总结</span></span></span></span></span></span></div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">3.对象的深拷贝和浅拷贝</span></span></div><div style="box-sizing: border-box; padding: 8px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(70, 99, 204); font-family: &quot;Courier New&quot;;">    var</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;;">obj1</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;;">=</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;;">{</span></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">        name</span><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(79, 93, 102); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">:</span><span style="font-size: 14px; color: rgb(40, 156, 151); font-family: &quot;Courier New&quot;;">"admin"</span></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">    }</span></span></div><div><br/></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(70, 99, 204); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">    var</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">obj2</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">=</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">{};</span></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">    for</span><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">(</span><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(70, 99, 204); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">var</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">i</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">in</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">obj1){</span></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">        obj2[i]</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">=</span><span style="font-size: 12px;" /><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">obj1[i];</span></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">    }</span></span></div><div><br/></div></div><div><br/></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">4.内置对象-Math</span></span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">Math对象用于执行 数学任务，Math 不像 Date 和 String 那样是对象的类，因此没有构造函数Math()。无需创建，直接把Math当成对象使用，就可以调用其所有的方法和属性。</span></div><div><br style="color: rgb(51, 51, 51);"/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">Math的方法</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    Math.round(3.6);        //四舍五入</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    Math.random();          //返回一个大于等于0到小于1的随机数</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    Math.max(a,b);          //返回较大的值</span></span></span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    Math.min(a,b);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">      //返回较小的值</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    Math.abs(num);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">      //返回绝对值</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    Math.ceil(3.6);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">   </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">      //向上取整</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    Math.floor(3.6);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;"> </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">      //向下取整</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    Math.pow(x,y);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">   </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">       //x的y次方</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    Math.sqrt</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">(num);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">   </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">      //开平方</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    Math.sin(x);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">   </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">         //x的正弦值，返回值在-1到1之间</span></font></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    Math.cos(x);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">         //x的余弦值，返回值在-1到1之间</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">sin和cos的x为弧度值，而非角度，弧度计算公式：2 * Math.PI / 360 * 角度</span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">Math的属性</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    Math.PI;                //约等于3.14159</span></span></span></div><div style="font-size: 12px;"><br/></div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">5.生成范围随机数</span></span></div><div style="box-sizing: border-box; padding: 8px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-ligatures: normal;">Math.round( Math.random() </span><span style="font-size: 14px; color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-variant-ligatures: normal;">* </span><span style="font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-ligatures: normal;">(max</span><span style="font-size: 14px; color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-variant-ligatures: normal;">-</span><span style="font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-ligatures: normal;">min) </span><span style="font-size: 14px; color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-variant-ligatures: normal;">+ </span><span style="font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-ligatures: normal;">min );</span></div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">6.十进制数字转16进制或8进制</span></span></div><div style="box-sizing: border-box; padding: 8px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="background-color: rgb(251, 250, 248); font-size: 12px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//十进制转其他</span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(70, 99, 204); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    var</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">x</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">=</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(173, 66, 239); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">110</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">;</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(x);</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(74, 138, 1); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(x.toString(<span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(173, 66, 239); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">2</span></span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">)</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">+</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(40, 156, 151); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">"这是2"</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">);</span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(74, 138, 1); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(x.toString(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(173, 66, 239); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">8</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">)</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">+</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(40, 156, 151); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">"这是8"</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">);</span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(74, 138, 1); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(x.toString(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(173, 66, 239); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">16</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">)</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">+</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(40, 156, 151); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">"这是16"</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">);</span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    //其他转十进制</span></span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(70, 99, 204); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    var</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">x</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">=</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(40, 156, 151); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">'110'</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">;</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(parseInt(x,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(173, 66, 239); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">2</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">));</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(parseInt(x,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(173, 66, 239); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">8</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">));</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(parseInt(x,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(173, 66, 239); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">16</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">));</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    //其他转其他</span></span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    //先用parseInt转成十进制再用toString转到目标进制</span></span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(parseInt(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(40, 156, 151); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">'ff'</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(173, 66, 239); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">16</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">).toString(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(173, 66, 239); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">2</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">));</span></font></div><div><br/></div></div><div><br/></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">编写一个函数，获得一个十六进制的随机颜色的字符串（如#20CD4F）</span></span></div><div><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;"><br/></span></span></div><div><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">编写一个函数，获得一个rgb的随机颜色的字符串（如rgb(123,216,45)</span><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">）</span></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">1.日期对象</span></span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    创建一个日期对象</span></span></span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(70, 99, 204); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    var</span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">d</span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(105, 137, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">= new</span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">Date();</span></div><div><br/></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    从日期对象获取信息</span></font></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(74, 138, 1); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d.getFullYear());    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//获取年</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(74, 138, 1); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d.getMonth());      </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//获取月，注意月份是从0开始</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d.getDate());        </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(165, 178, 185); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//获取日</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d.getDay());         </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(165, 178, 185); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//获取周</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    </span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(74, 138, 1); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d.getHours());      </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//获取小时</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d.getMinutes());     </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(165, 178, 185); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//获取分钟</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d.getSeconds());     </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(165, 178, 185); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//获取秒数</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d.getMilliseconds());</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(165, 178, 185); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//获取毫秒</span></font></div><div><br/></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    时间戳</span></font></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(74, 138, 1); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d.getTime());        </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//获取从1970年1月1日至今的毫秒</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    </span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(74, 138, 1); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d)                  </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//返回本地时间，包含年月日星期时分秒</span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    设置日期：</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        1.粗野模式，简单粗暴，但是会清零时分秒</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            var d = new Date("2008/8/8");</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        2.复杂模式</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            var d = new Date();</span></span></span></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">d.setFullYear(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(173, 66, 239); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">2009</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">);    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//设置年</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">            d.setMonth(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(173, 66, 239); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">6</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">);          </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(165, 178, 185); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//设置月，超过11，累加年</span></font></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">            d.setDate(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(173, 66, 239); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">27</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">);          </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//设置日，超过最大日期，累加月</span></font></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">            d.setHours(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(173, 66, 239); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">40</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">);         </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//设置小时，超过24，累加天</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">            d.setMinutes(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(173, 66, 239); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">40</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">);      </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//设置分钟，超过60，累加小时</span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">            d.setSeconds(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(173, 66, 239); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">40</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">);      </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(165, 178, 185); font-family: &quot;Courier New&quot;; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//设置秒，超过60，累加分钟</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">            d.setMilliseconds(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(173, 66, 239); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">40</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">);  </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(165, 178, 185); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//设置毫秒，超过1000，累加秒</span></font></div><div><br/></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">            d.setTime(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(173, 66, 239); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">10000</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">)        </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(165, 178, 185); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//设置从1970年1月1日过去了多少毫秒</span></font></div><div><br/></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(165, 178, 185); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">        <span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(74, 138, 1); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">console</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">.log(d)</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(6, 6, 6); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">  </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(165, 178, 185); font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: normal;">//返回更改后的年月日 时分秒</span></span></font></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">    注意set系列的返回值</span></span></span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">       </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">console.log(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">d.setFullYear(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">2009</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">));</span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">       </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(6, 6, 6); font-family: &quot;Courier New&quot;; font-variant-caps: normal; font-variant-ligatures: normal;">//返回从1970年1月1日，到当前设置的时间的毫秒数</span></div><div style="font-size: 12px;"><br/></div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">2.计算两个日期的时间差值</span></span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><br/></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;">作业：</span><span style="font-size: 14px; font-family: &quot;Courier New&quot;;">封装一个函数，能正常输出日期和时间，如2017年12月13日星期三15：04：04</span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;">求出，今天距离南京大屠杀发生的时期过去了多少天，多少小时，分钟</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;">    1937年12月13日10：01：00</span></span></span></div><div><br/></div><div><br/></div><div>1997.7.1        0:0:0</div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">3.延时器和计时器</span></span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    延时器：setTimeout(function(){</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">               console.log(1);</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">           },100)</span></span></span></span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    语法：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">setTimeout(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">函数或者代码串，指定的时间</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">毫秒</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">));</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    在指定的毫秒数后只执行一次函数或代码。</span></span></span></span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    清除延迟器：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">clearTimeout();</span></font></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">  </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;"> 定时器：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">setInterval(function(){</span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">               console.log(1);</span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">           },100)</span></span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    语法：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">setInterval(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">函数或者代码串，指定的时间</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">毫秒</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">));</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    按照指定的周期</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">毫秒</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">)</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">不断的执行函数或者是代码串。</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    清除定时器：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">clearInterval();</span></font></div><div><br/></div></div><div><br/></div><div><br/></div><div><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">4.扩展：日期函数封装（dateUtil.js）（封装常见功能）</span></div><div><span style="font-size: 14px; font-family: &quot;Courier New&quot;;">    1.输出正常的日期格式</span></div><div><span style="font-size: 14px; font-family: &quot;Courier New&quot;;">    2.计算两个日期之间的天数</span></div><div><span style="font-size: 14px; font-family: &quot;Courier New&quot;;">    3.补零</span></div><div><br/></div><div><br/></div><div><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">1.倒计时</span></div><div><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">从10到0，停止，//点击按钮还原倒计时，到0，再停-----------------------点击，再还原</span></div><div><br/></div><div><br/></div><div><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">2.用户输入两个日期，要求返回中间差了几天</span></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 14pt;"><span style="font-size: 14pt; font-family: &quot;Courier New&quot;;">3.随机点名</span></span></div><div><a href="DAY08%EF%BC%9AMath%E5%92%8CDate.resources/index.html">index.html</a></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div></body></html>